//
//  Edit_TelephonyViewController.m
//  fxxiaoke
//
//  Created by 鞠超 on 16/9/10.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "Edit_TelephonyViewController.h"

@interface Edit_TelephonyViewController () <UIScrollViewDelegate, UITextFieldDelegate>

@property (nonatomic, strong) UIScrollView * scrollView;

@property (nonatomic, strong) UITextField * text_Host;
@property (nonatomic, strong) UITextField * text_Extension;

@end

@implementation Edit_TelephonyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void )p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    
    _lblTitle.text = @"电话";
    
    //左返回
    UIImageView * image_LeftRetrun = [[UIImageView alloc] initWithFrame:CGRectMake(11, 31.5, 25, 25)];
    image_LeftRetrun.userInteractionEnabled = YES;
    image_LeftRetrun.image = [UIImage imageNamed:@"Left-return.png"];
    [_topView addSubview:image_LeftRetrun];
    
    UILabel * lbl_return = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_LeftRetrun.frame) - 6, 35, 70, 15)];
    lbl_return.text = @"编辑资料";
    lbl_return.textColor = [UIColor whiteColor];
    lbl_return.font = [UIFont systemFontOfSize:17];
    [_topView addSubview:lbl_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 22, 90, 40);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    //右保存
    UIButton * btn_Edit = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_Edit.frame = CGRectMake(SCREEN_WIDTH - 5 - 50, 20 + 7, 50, 30);
    [btn_Edit setTitle:@"保存" forState:(UIControlStateNormal)];
    [btn_Edit setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    btn_Edit.titleLabel.font = [UIFont systemFontOfSize:17];
    [_topView addSubview:btn_Edit];
    [btn_Edit addTarget:self action:@selector(btn_EditAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//右保存
- (void )btn_EditAction:(UIButton *)sender
{
//    NSLog(@"点击保存并跳页");
    
    [self.navigationController popViewControllerAnimated:YES];
}

//tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
    
    [self.text_Host becomeFirstResponder];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    self.scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView.contentSize = CGSizeMake(0, SCREEN_HEIGHT - 64);
    self.scrollView.delegate = self;
    [self.view addSubview:self.scrollView];
    
    
    CGFloat length_X = (SCREEN_WIDTH - 45) / 4;
    
    UIView * view_Host = [[UIView alloc] initWithFrame:CGRectMake(15, 15, length_X * 2.75, 40)];
    view_Host.backgroundColor = [UIColor whiteColor];
    view_Host.layer.borderColor = [UIColor grayColor].CGColor;
    view_Host.layer.borderWidth = 0.5;
    [self.scrollView addSubview:view_Host];
    
    self.text_Host = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, length_X * 2.75 - 15, 30)];
    self.text_Host.delegate = self;
    self.text_Host.placeholder = @"座机号";
    self.text_Host.font = [UIFont systemFontOfSize:16.0f];
    self.text_Host.returnKeyType = UIReturnKeyDone;
    [view_Host addSubview:self.text_Host];
    
    //
    UIView * lbl_line = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(view_Host.frame) + 5, 15 + 19.5, 5, 1)];
    lbl_line.backgroundColor = [UIColor grayColor];
    [self.scrollView addSubview:lbl_line];
    
    //
    UIView * view_Extension = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(view_Host.frame) + 15, 15, length_X * 1.25, 40)];
    view_Extension.backgroundColor = [UIColor whiteColor];
    view_Extension.layer.borderColor = [UIColor grayColor].CGColor;
    view_Extension.layer.borderWidth = 0.5;
    [self.scrollView addSubview:view_Extension];
    
    self.text_Extension = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, length_X * 1.25 - 15, 30)];
    self.text_Extension.delegate = self;
    self.text_Extension.placeholder = @"分机号";
    self.text_Extension.font = [UIFont systemFontOfSize:16.0f];
    self.text_Extension.returnKeyType = UIReturnKeyDone;
    [view_Extension addSubview:self.text_Extension];
}

#pragma mark - textfield代理
- (BOOL )textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    
    return YES;
}














@end
